#ifndef _LIST_H_XWW_20040728_103415_
#define _LIST_H_XWW_20040728_103415_
//List.h : ????t??

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef BOOL_TYPE
#define BOOL_TYPE
typedef int		BOOL;
#endif

#ifndef	NULL
#define	NULL	((void*) 0)
#endif

#ifndef	FALSE
#define	FALSE	(0)
#endif

#ifndef	TRUE
#define	TRUE	(!FALSE)
#endif


typedef void*           ListPosition;

typedef struct _List	List;

typedef int (*FN_Compare)(const void*, const void*); //memcmp

/* Create and free									*/
extern List*		List_create();
extern void			List_free(List*);

/* Status                                           */
extern int          List_count(List* me);
extern BOOL         List_empty(List* me);

/* Head/Tail Access                                 */
extern void*        List_head(List* me);
extern void*        List_tail(List* me);

/* Operations                                       */
extern void*        List_removeHead(List* me);
extern void*        List_removeTail(List* me);
extern ListPosition List_addHead(List* me, const void* newElement);
extern ListPosition List_addTail(List* me, const void* newElement);
extern void         List_clear(List* me);

/* Iteration                                        */
extern ListPosition List_headPosition(List* me);
extern ListPosition List_tailPosition(List* me);
extern void*		List_next(List* me, ListPosition* pp);
extern void*		List_prev(List* me, ListPosition* pp);

/* Retrieval/Modification                           */
extern void*        List_get(List* me, ListPosition p);
extern void         List_set(List* me, ListPosition p, const void* newElement);
extern void         List_remove(List* me, ListPosition p);

/* Insertion                                        */
extern ListPosition List_insertBefore(List* me, ListPosition p, const void* newElement);
extern ListPosition List_insertAfter(List* me, ListPosition p, const void* newElement);

/* Searching                                        */
extern ListPosition List_find(List* me, const void* searchValue);
extern ListPosition List_findEx(List* me, const void* searchValue, ListPosition startAfter,
						int (*compare)(const void*, const void*));
extern ListPosition List_findIndex(List* me, int index);

/* Helper											*/
extern void			List_destructor(List* me, void (*destructFun)(void*));

#ifdef __cplusplus
}
#endif

#endif //_LIST_H_XWW_20040728_103415_
